package com.taptech.doufu.manager;

import com.taobao.weex.InitConfig;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.ui.component.Textarea;
import com.taobao.weex.ui.component.list.WXListComponent;
import com.taobao.weex.utils.WXResourceUtils;
import com.taobao.weex.utils.WXUtils;
import com.taptech.doufu.ui.adapter.WXImageAdapter;
import com.taptech.doufu.weex.QLXGlobal;
import com.taptech.doufu.weex.TFHotUpdateUtil;
import com.taptech.doufu.weex.TFWXUtil;
import com.taptech.doufu.weex.module.TFBridgeMoule;
import com.taptech.doufu.weex.module.TFCacheModule;
import com.taptech.doufu.weex.module.TFConfigModule;
import com.taptech.doufu.weex.module.TFEventModule;
import com.taptech.doufu.weex.module.TFHudModule;
import com.taptech.doufu.weex.module.TFLogModule;
import com.taptech.doufu.weex.module.TFNotifyModule;
import com.taptech.doufu.weex.module.TFStatusBarModule;
import com.taptech.doufu.weex.module.TFStreamModule;
import com.taptech.doufu.weex.module.TFUserLogModule;
import com.taptech.doufu.ui.view.weex.QLXDivComponent;
import com.taptech.doufu.ui.view.weex.QLXTextComponet;
import com.taptech.doufu.ui.view.weex.TFEmbed;

/**
 * Created by qlx on 2016/12/3.
 */

public class TFSDKManager {
    private static TFSDKManager instance = new TFSDKManager();

    /*
     * 单例
     */
    public static TFSDKManager getInstance(){
        return instance;
    }

    public void initSDK(){
        initWeexSDK();
    }


    /*
    * 设置Weex SDK
    */
    private synchronized void initWeexSDK(){
        InitConfig config=new InitConfig.Builder().setImgAdapter(new WXImageAdapter()).build();
        WXSDKEngine.initialize(QLXGlobal.getApplication(),config);
        try {
            WXSDKEngine.registerComponent("qtext", QLXTextComponet.class);
            WXSDKEngine.registerComponent("qdiv", QLXDivComponent.class);
            WXSDKEngine.registerComponent("qtextarea", Textarea.class);
            WXSDKEngine.registerComponent("qembed", TFEmbed.class);
            WXSDKEngine.registerModule("event", TFEventModule.class);
            WXSDKEngine.registerModule("notify", TFNotifyModule.class);
            WXSDKEngine.registerModule("bridge", TFBridgeMoule.class);
            WXSDKEngine.registerModule("dfconfig", TFConfigModule.class);
            WXSDKEngine.registerModule("http", TFStreamModule.class);
            WXSDKEngine.registerModule("hud", TFHudModule.class);
            WXSDKEngine.registerModule("log", TFLogModule.class);
            WXSDKEngine.registerModule("cache", TFCacheModule.class);
            WXSDKEngine.registerModule("statusbar", TFStatusBarModule.class);
            WXSDKEngine.registerModule("userlog", TFUserLogModule.class);
            WXSDKEngine.registerComponent("oldlist", WXListComponent.class);

            TFHotUpdateUtil.upZipLocalWeex();
        }catch (Exception e){
            e.printStackTrace();
        }
    }



}
